// 引入样式
require("./zjf_sport_run.less");
let dom = require("../../assets/js/zjf-dom.js");
let axios = require("axios");
document.addEventListener("DOMContentLoaded", function () {
	axios.defaults.baseURL = "http://fitness.h5.itsource.cn:3701";
	let token = localStorage.getItem("token");
	axios.defaults.headers.common["Authorization"] = "Bearer " + token;
	// 引入头部和尾部
	dom.nav("sport");
	dom.nav2("run");

	// 获取方法
	function $(v) {
		return document.querySelector(v);
	}
	// 点击开始
	$("#begin").addEventListener("click", function () {
		console.log(1);
		$("#mask").style.display = "block";
		$("#box").style.display = "block";
		$("#begin").style.display = "none";
		let n = 3;
		setInterval(function () {
			n--;
			$("#box").textContent = n;
			if (n === 0) {
				location.href = "./zjf_sport_running.html";
			}
		}, 1000);
	});
	axios.get("/api/exercise").then((v) => {
		$("#num").textContent = (v.data.data.sum7Meter / 1000).toFixed(2);
	});
});
